/*
 * @Author: wangchao
 * @Date: 2024-10-04 12:43:36
 * @LastEditors: wangchao
 * @LastEditTime: 2024-10-09 13:10:03
 * @FilePath: \JD-RTT-Driver\applications\u_app_start.h
 * @Description:
 * Copyright (c) 2024 by Bingshan Guardian, All Rights Reserved.
 */
#ifndef _U_APP_START_H_
#define _U_APP_START_H_

#include <rtthread.h>
#include <rtdevice.h>
#include "board.h"

/**
 *  APP启动模式定义
 */
typedef enum
{
    START_DO_INITIAL_CHARGE,
    START_DO_STANDBY,
    START_DO_CHARGING,
    START_DO_DISCHARGING,
    START_DO_LIQUID_MIXING,
} VAR_APP_START_MODE;

//
typedef enum
{
    INIT_CHARGE_STEP_OPERATE_VALVE,        // 操作阀门
    INIT_CHARGE_STEP_CHECK_VALVE_STATUS,   // 检查阀门状态
    INIT_CHARGE_STEP_OPERATION_TIMEOUT,    // 操作阀门超时
    INIT_CHARGE_STEP_HMI_FEEDBACK_1,       // HMI反馈1
    INIT_CHARGE_STEP_START_STRATEGY,       // 启动策略
    INIT_CHARGE_STEP_WAIT_FLOW_STABILITY,  // 等待流量稳定
    INIT_CHARGE_STEP_DELAY_WAIT_1,         // 延时等待1
    INIT_CHARGE_STEP_PCS_SET_PARAMS,       // PCS设定参数
    INIT_CHARGE_STEP_START_PCS,            // 启动PCS
    INIT_CHARGE_STEP_HMI_FEEDBACK_2,       // HMI反馈2
    INIT_CHARGE_STEP_CHECK_CHARGE_RESULT,  // 检查充电结果
    INIT_CHARGE_STEP_DELAY_WAIT_2,         // 延时等待2
    INIT_CHARGE_STEP_STOP_PCS,             // 停止PCS
    INIT_CHARGE_STEP_HMI_FEEDBACK_3,       // HMI反馈3
    INIT_CHARGE_STEP_GO_TO_STANDBY         // 转入待机
} INIT_CHARGE_STEP;

typedef enum
{
    STANDBY_STEP_OPERATE_VALVE,        // 操作阀门
    STANDBY_STEP_CHECK_VALVE_STATUS,   // 检查阀门状态
    STANDBY_STEP_OPERATION_TIMEOUT,    // 操作阀门超时
    STANDBY_STEP_START_STRATEGY,       // 启动策略
    STANDBY_STEP_WAIT_FLOW_STABILITY,  // 等待流量稳定
    STANDBY_STEP_STOP_PCS,             // 停止PCS
    STANDBY_STEP_HMI_FEEDBACK_1,       // HMI反馈1
} STANDBY_STEP;

typedef enum
{
    STANDARD_CHARGE_STEP_OPERATE_VALVE,            // 操作阀门
    STANDARD_CHARGE_STEP_CHECK_VALVE_STATUS,       // 检查阀门状态
    STANDARD_CHARGE_STEP_VALVE_OPERATION_TIMEOUT,  // 操作阀门超时
    STANDARD_CHARGE_STEP_START_STRATEGY,           // 启动策略
    STANDARD_CHARGE_STEP_WAIT_FLOW_STABILITY,      // 等待流量稳定
    STANDARD_CHARGE_STEP_PCS_SET_PARAMS,           // PCS设定参数
    STANDARD_CHARGE_STEP_START_PCS,                // 启动PCS
    STANDARD_CHARGE_STEP_HMI_FEEDBACK_1,           // HMI反馈1
    STANDARD_CHARGE_STEP_CHECK_CHARGE_RESULT_1,    // 检查充电结果1
    STANDARD_CHARGE_STEP_DELAY_WAIT_1,             // 延时等待1
    STANDARD_CHARGE_STEP_PCS_MODIFY_PARAMS,        // PCS修改参数
    STANDARD_CHARGE_STEP_HMI_FEEDBACK_2,           // HMI反馈2
    STANDARD_CHARGE_STEP_CHECK_CHARGE_RESULT_2,    // 检查充电结果2
    STANDARD_CHARGE_STEP_DELAY_WAIT_2,             // 延时等待2
    STANDARD_CHARGE_STEP_STOP_PCS,                 // 停止PCS
    STANDARD_CHARGE_STEP_HMI_FEEDBACK_3,           // HMI反馈3
    STANDARD_CHARGE_STEP_STATE_HOLD                // 状态保持
} STANDARD_CHARGE_STEP;

typedef enum
{
    STANDARD_DISCHARGE_STEP_OPERATE_VALVE,             // 操作阀门
    STANDARD_DISCHARGE_STEP_CHECK_VALVE_STATUS,        // 检查阀门状态
    STANDARD_DISCHARGE_STEP_VALVE_OPERATION_TIMEOUT,   // 操作阀门超时
    STANDARD_DISCHARGE_STEP_START_STRATEGY,            // 启动策略
    STANDARD_DISCHARGE_STEP_WAIT_FLOW_STABILITY,       // 等待流量稳定
    STANDARD_DISCHARGE_STEP_CHECK_OCV,                 // 检查OCV
    STANDARD_DISCHARGE_STEP_OCV_LOW_HANDLING,          // OCV低处理
    STANDARD_DISCHARGE_STEP_PCS_SET_PARAMS,            // PCS设定参数
    STANDARD_DISCHARGE_STEP_START_PCS,                 // 启动PCS
    STANDARD_DISCHARGE_STEP_HMI_FEEDBACK_1,            // HMI反馈1
    STANDARD_DISCHARGE_STEP_CHECK_DISCHARGE_RESULT_1,  // 检查充电结果1
    STANDARD_DISCHARGE_STEP_DELAY_WAIT_1,              // 延时等待1
    STANDARD_DISCHARGE_STEP_PCS_MODIFY_PARAMS,         // PCS修改参数
    STANDARD_DISCHARGE_STEP_HMI_FEEDBACK_2,            // HMI反馈2
    STANDARD_DISCHARGE_STEP_CHECK_DISCHARGE_RESULT_2,  // 检查充电结果2
    STANDARD_DISCHARGE_STEP_DELAY_WAIT_2,              // 延时等待2
    STANDARD_DISCHARGE_STEP_STOP_PCS,                  // 停止PCS
    STANDARD_DISCHARGE_STEP_HMI_FEEDBACK_3,            // HMI反馈3
    STANDARD_DISCHARGE_STEP_STATE_HOLD                 // 状态保持
} STANDARD_DISCHARGE_STEP;

typedef enum
{
    MIXING_STEP_OPERATE_VALVE,            // 操作阀门
    MIXING_STEP_CHECK_VALVE_STATUS,       // 检查阀门状态
    MIXING_STEP_VALVE_OPERATION_TIMEOUT,  // 操作阀门超时
    MIXING_STEP_START_STRATEGY,           // 启动策略
    MIXING_STEP_WAIT_FLOW_STABILITY,      // 等待流量稳定
    MIXING_STEP_CHECK_SHUTDOWN,           // 检查是否停机
    MIXING_STEP_WAIT_SHUTDOWN_COMPLETE,   // 等待停机完成
    MIXING_STEP_DELAY_WAIT_1,             // 延时等待1
    MIXING_STEP_CLOSE_MIX_VALVE,          // 关闭混液阀
    MIXING_STEP_WAIT_MIX_VALVE_CLOSE,     // 等待混液阀关闭
    MIXING_STEP_DELAY_WAIT_2,             // 延时等待2
    MIXING_STEP_HMI_FEEDBACK_1            // HMI反馈1
} MIXING_STEP;

VAR_APP_START_MODE get_current_app_start_mode(void);
void set_current_app_start_mode(VAR_APP_START_MODE mode);
void app_do_start_runner(void);

#endif
